function LineChart(chartDiv,title,yAxisName,startDate,endDate,dataMap){
	this.chartDiv = chartDiv;
	this.title = title;
	this.yAxisName = yAxisName;
	this.startDate=startDate;
	this.endDate = endDate;
	this.dataMap = dataMap;
	this.chartString = "";
	this.keyPattern ="";
	this.seriesNameArray ={};
	this.seriesKeyArray={};
};

LineChart.prototype.setKeyPattern = function(keyPattern){
	this.keyPattern = keyPattern;
};

LineChart.prototype.generateDataString = function(){
	this.chartString ="<chart caption='"+ this.title+"' baseFontSize='12' palette='3' YAxisName='"+ this.yAxisName+"' numdivlines='8' lineThickness='2' showValues='0' anchorRadius='3' anchorBgAlpha='50' numVDivLines='11' showAlternateVGridColor='1' alternateVGridAlpha='3' formatNumber='0' formatNumberScale='0' animation='1' numVisiblePlot='12'>";
	var FORMAT ="yyyy-MM-dd";
	var DAY = 24*60*60*1000;
	var start = this.startDate.valueOf();
	var end = this.endDate.valueOf();
	this.chartString+="<categories >";
	for(var time = start;time<=end;time+=DAY){
		var day = new Date();
		day.setTime(time);
		var key = day.format("MM-dd");
		this.chartString+="<category label='"+key+"' />";
	}
	this.chartString+="</categories>";
	var seriesLenght = this.seriesKeyArray.length;
	var showSeries = true;
	if(seriesLenght<=1){
		showSeries = false;
	}
	for(var i = 0;i<seriesLenght;i++){
		this.chartString+="<dataset ";
		if(showSeries){
			var seriesName = this.seriesNameArray[i];
			if(seriesName === undefined){
				seriesName="";
			}
			this.chartString+="seriesName='"+seriesName+"'";
		}
		this.chartString+=">";
		for(var time = start;time<=end;time+=DAY){
			var day = new Date();
			day.setTime(time);
			var key = this.keyPattern.replace("{0}",day.format(FORMAT));
			if(key.indexOf("{1}")>-1){
				key = key.replace("{1}",this.seriesKeyArray[i]);
			}
			var value = this.dataMap[key];
			if (value === undefined){
				value =0;
			}
    		this.chartString+='<set value="'+value+'"/>';
		}
		this.chartString+="</dataset>";
	}
	this.chartString+="</chart>";
};
LineChart.prototype.draw = function(seriesKeyArray,seriesNameArray){
	this.seriesKeyArray = seriesKeyArray;
	this.seriesNameArray = seriesNameArray;
	this.generateDataString();
	var chart = new FusionCharts("../static/FusionCharts/ScrollLine2D.swf", "LineChartId", "726", "325", "0", "0");
    chart.setXMLData(this.chartString);
    chart.render(this.chartDiv);
};